const mongoose = require('mongoose');

let uri = 'mongodb://39.105.153.251/reword';

mongoose.connect(uri, {useNewUrlParser: true});
let db = mongoose.connection;

//监听是否有异常
db.on('error', (err) =>  { 
    console.log("MongoDB 数据库连接异常: ", err);
});
//用来监听数据库是否连接成功
db.on('connected', function () {
	console.log('MongoDB 数据库连接成功');
});
db.on('disconnected', () => {
	console.log('MongoDB 数据库没有连接');
})

module.exports = mongoose;